function bio_scratch
%standing question: what do i do with the walk when i encounter an 'N' in the DNA sequence? 
%currently, i just set its numeric encoding to 0

load bursetData

sequenceToLookAt = ceil(length(sequences)*rand()); %choose at random
walks=plotDNAWalks(sequences(sequenceToLookAt));



function walks=plotDNAWalks(data)
%this is what I called a "Type 1" walk in the proposal

figure(5)
clf

deltas = [1; -1/3; -1/3; -1/3];
%deltas = [.126 .1335 .0806 .1340];
labels = ['A' 'T' 'G' 'C'];
for i=1:4
    numericEncoding = zeros(1,length(data.sequence)); %i assume that an 'N' should be 0
    for j=1:4
        numericEncoding(find(data.sequence == labels(j))) = deltas(j);
    end
    walk = cumsum(numericEncoding);
    walk = walk(1:512);
    %walk = (walk - mean(walk))./std(walk);
    %walk = walk - mean(walk);
    %walk = walk ./ (max(abs(walk)));
    
    walks(i, :) = walk;
    deltas = circshift(deltas, 1); %makes labels(i) have a score of 1
    
    
    %%%
    %n=512;
    %walk = sin(linspace(0,8*pi, n));
    %walk = [walk (sin(linspace(0,28*pi,n)))];
    %walk = linspace(0,5,2*n) +walk;
    
    %{
    subplot(5,2,[1 2])
    plot(walk)
    title('time series')
    for level=1:4
        [coefs, l] = wavedec(walk, 2^level, 'db1');
        subplot(5,2,level*2+1);
        plot(coefs);
        title(sprintf('coefs, level %d, numel = %d', level, numel(coefs)));
        subplot(5,2,level*2+2);
        plot(l);
        title('bookkeeping vector');
    end   
    %}
    
    figure(i)
    clf
    set(gcf, 'Position', [10 10 800 800]);
    scales =1:1:128;
    coefs = cwt(walk,scales,'db4');
    wscalogram('image',coefs,'scales',scales,'ydata',walk);
    colormap jet
        
    figure(5)
    subplot(4,1,i)
    plot(walk, 'r')
    xlabel('sequence position', 'fontsize', 12)
    ylabel('walk value', 'fontsize', 12)
    %set(gca, 'xlim', [0 length(data.sequence)])
    title(sprintf('Type 1 DNA Walk for %s with %s = %.2f, %s = %.2f, %s = %.2f, %s = %.2f', data.name, labels(1), deltas(1), labels(2), deltas(2), labels(3), deltas(3), labels(4), deltas(4)), 'fontsize', 12)
    n=size(data.regions, 1);
    for j=1:n
        hold on
        if (data.regions(j,1) > length(walk)  || data.regions(j,2) > length(walk))
            break;
        end
        plot(data.regions(j, 1):data.regions(j, 2), walk(data.regions(j, 1):data.regions(j, 2)), '-b')
    end

end